package WaiBao;

import java.util.Arrays;

public class XueShuFan {
    public static void main(String[] args) {
        String[] name = {"王志远(班长)", "王晓涵(副班长)", "张合元(组织委员)", "李世超(体育委员)", "郭静婷", "李值", "李志", "李寻", "王志阳", "王大锤", "李大彪", "王胖子",
                "肖战", "王一博", "鹿晗", "张艺兴", "韩星", "韩愈", "白居易", "杜甫", "李贺", "李白", "欧阳修", "上官婉儿", "程咬金", "廉颇", "蒙恬", "夏洛特",
                "林俊杰", "薛书凡(学生)"};//考生本人:薛书凡(学生)
        int[] age = {18, 19, 21, 18, 19, 20, 21, 21, 19, 19, 18, 18, 18, 20, 21, 19, 18, 19, 18, 20, 19, 19, 20, 20, 20, 18, 20, 19, 18, 19};
        double[] w1 = {68, 88, 85, 90, 88, 69, 78, 59, 60, 70, 90, 87, 85, 79, 65, 68, 69, 99, 96, 88, 92, 91, 95, 85, 75, 74, 74, 84, 89, 92};
        double[] w2 = {69, 84, 77, 69, 68, 97, 88, 99, 90, 90, 90, 67, 86, 75, 65, 65, 86, 79, 66, 78, 82, 71, 85, 85, 75, 89, 74, 79, 84, 93};
        double[] w3 = {38, 89, 89, 95, 99, 99, 69, 89, 80, 60, 93, 87, 85, 85, 65, 98, 89, 79, 96, 63, 92, 81, 95, 85, 76, 88, 73, 78, 78, 94};

        double dum1;//代表每个学生的总分
        double avag;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            dum1 = w1[i] + w2[i] +w3[i];
//            avag = (dum1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + dum1);
//            System.out.println(name[i] + "的平均分为:" +avag);
//        }
//
//
//        double Res = 0, Ave = 0;
//        double[] Array = new double[30];
//        for (int i = 0; i < 30; i++) {
//            Res = w1[i] + w2[i] + w3[i];
//            avag = (Res * 1.0) / 3;
//            Array[i] = avag;
//        }
//
//        for (int i = 0; i < Array.length - 1; i++) {
//            for (int j = 0; j < Array.length - i - 1; j++) {
//                if (Array[j] < Array[j + 1]) {
//                    double temp = Array[j];
//                    Array[j] = Array[j + 1];
//                    Array[j + 1] = temp;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(Array[i]);
//        }



        double h1 = 0, h2 = 0, h3 = 0;//计算每门课的平均分
        double f1 = 0, f2 = 0, f3 = 0;//计算每门课标准差
        double n1 = 0, n2 = 0, n3 = 0;//计算每门课中位数
        double sum2 = 0;
        for (int i = 0; i < w1.length; i++) {
            sum2+=w1[i];
        }
        h1 = (sum2*1.0)/30;
        System.out.println("分析化学的班级平均分为:"+h1);
        double Sum = 0;
        for (int i = 0; i < w2.length; i++) {
            Sum+=w2[i];
        }
        h2 = (Sum*1.0)/30;
        System.out.println("线性代数的班级平均分为:"+h2);
        double sum = 0;
        for (int i = 0; i <w3.length; i++) {
            sum+=w3[i];
        }
        h3 = (sum*1.0)/30;
        System.out.println("有机化学的班级平均分为:"+h3);

        double c1 = 0,c2 = 0,c3 = 0;
        for (int i = 0; i < w1.length; i++) {
            c1+= (w1[i] - h1)*(w1[i] - h1);
        }
        f1 = Math.sqrt(c1*1.0/30);
        System.out.println("分析化学的班级标准差为:"+f1);

        for (int i = 0; i < w2.length; i++) {
            c2+= (w2[i] - h2)*(w2[i] - h2);
        }
        f2 = Math.sqrt(c2*1.0/30);
        System.out.println("线性代数的班级标准差为:"+f2);

        for (int i = 0; i < w3.length; i++) {
            c3+= (w3[i] - h3)*(w3[i] - h3);
        }
        f3 = Math.sqrt(c3*1.0/30);
        System.out.println("有机化学的班级标准差为:"+f3);

        Arrays.sort(w1);
        Arrays.sort(w2);
        Arrays.sort(w3);
        n1 =( w1[15]+w1[14])*1.0/2;
        n2 =( w2[15]+w2[14])*1.0/2;
        n3 =( w3[15]+w3[14])*1.0/2;
        System.out.println("分析化学的中位数为:"+n1);
        System.out.println("线性代数的中位数为:"+n2);
        System.out.println("有机化学的中位数为:"+n3);


    }
}
